/*jslint browser: true,es5: true*/
/*global $, jQuery, window, requirejs, require, define*/
requirejs.config({
    paths: {
        jquery: "/static/libs/jquery.min",
        "jquery.ui": "/static/libs/jquery-ui.min",
        "jquery.cookie": "/static/libs/jquery.cookie",
        "lhmcv.ui": "/static/apps/ui/ui"
    },
    shim: {
        "jquery.ui": ["jquery"],
        "lhmcv.ui": ["jquery", "jquery.ui"]
    }
});

String.prototype.format = function (replace_dict) {
    "use strict";
    var result = this,
        key,
        value,
        reg,
        index;
    for (key in replace_dict) {
        if (replace_dict.hasOwnProperty(key)) {
            value = replace_dict[key];
            reg = new RegExp("({" + key + "})", "g");
            result = result.replace(reg, value);
        }
    }
    return result;
};

// Start the main app logic.
requirejs(["jquery", "lhmcv.ui"], function () {
    "use strict";
    $("#accordion").accordion();
    $("#autocomplete").combobox({
        datalist: [
			{pk: 1, name: "ActionScript"},
			{pk: 2, name: "AppleScript"},
			{pk: 3, name: "Asp"},
			{pk: 4, name: "BASIC"},
			{pk: 5, name: "C"},
			{pk: 6, name: "C++"},
			{pk: 7, name: "Clojure"},
			{pk: 8, name: "COBOL"},
			{pk: 9, name: "ColdFusion"},
			{pk: 10, name: "Erlang"},
			{pk: 11, name: "Fortran"},
			{pk: 12, name: "Groovy"},
			{pk: 13, name: "Haskell"},
			{pk: 14, name: "Java"},
			{pk: 15, name: "JavaScript"},
			{pk: 16, name: "Lisp"},
			{pk: 17, name: "Perl"},
			{pk: 18, name: "PHP"},
			{pk: 19, name: "Python"},
			{pk: 20, name: "Ruby"},
			{pk: 21, name: "Scala"},
			{pk: 22, name: "Scheme"}
        ]
    });
    $("#button").button();
    $("#radioset").buttonset();
    $("#tabs").tabs();
    
    $("#dialog").dialog({
        autoOpen: false,
        width: 400,
        buttons: [
            {
                text: "OK",
                click: function () {
                    $(this).dialog("close");
                }
            },
            {
                text: "Cancel",
                click: function () {
                    $(this).dialog("close");
                }
            }
        ]
    });
    // Link to open the dialog
    $("#dialog-link").button({
        icons: {
            primary: "ui-icon-newwin"
        }
    }).click(function (event) {
        $("#dialog").dialog("open");
        event.preventDefault();
    });
    
    $("#datepicker").datepicker();
    
    $("#progressbar").progressbar({
        value: 9,
        max: 10
    });
    
    $("#spinner").spinner();
    $("#menu").menu();
    /*$('#files').tree({
        expanded: 'li:first'
    });*/
    $('#files').iNavi();
    
        
});